import {defineStore} from "pinia";
import myAxios from "../http/myAxios";
import {responseDataHttp} from "../type/response";

// 上传

export const useUploadStore = defineStore('upload', () => {

    // 上传图片
    async function UploadImg(file: File) {
        const data = new FormData()
        data.append("file", file)

        const result = await myAxios<responseDataHttp<{ image: string }>>("/upImage", {
            method: "POST",
            data: data,
        }).then(r => r.data)

        return result.data.image
    }

    return {
        UploadImg
    }
})